import java.util.Scanner;

public class Queens {
	final static int EMPTY = 0;
	final static int QUEEN = 1;
	final static int BLOCKED = 2;
	static int[][] Board;
	static int n;
	static int count = 0;

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		print("Enter the size of n");
		n = s.nextInt();
		s.close();

		Board = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				Board[i][j] = EMPTY;
			}
		}
		place(0, 0);

		for (int y = 0; y < n; y++) {
			for (int x = 0; x < n; x++) {
				System.out.print(Board[x][y]);
			}
			System.out.print("\n");
		}
	}

	public static void place(int x, int y) {
		if (x < n && y < n) {
			ClearRight(x);
			boolean found = false;
			while (!found && y < n) {
				if (Check(x, y))
					found = true;
				y++;
			}
			if (found) {
				//y--;
				Board[x][y - 1] = QUEEN;
				count++;
				while (count < n && count < n)
					place(x + 1, y);
				return;
			}
			count--;
			return;
		} else {
			return;
		}
	}
	
	public static void ClearRight(int x) {
		for(int i = x; i < n; i++) {
			for(int j = 0; j < n; j++) {
				Board[i][j] = EMPTY;
			}
		}
	}

	public static boolean Check(int x, int y) {
		for (int i = 0; i < n; i++) {
			if (Board[x][i] == QUEEN && !(i == x))
				return false;
			if (Board[i][y] == QUEEN && !(i == y))
				return false;
		}
		for (int i = x - y; i < n; i++) {
			int j = 0;
			if (i < 0) {
				j = -1 * i;
				i = 0;
			}
			if (Board[i][j] == QUEEN && !(i == x && j == y))
				return false;
			j++;
		}
		return true;
	}

	public static void print(String str) {
		System.out.println(str);
	}

	public static void Test() {
		Board[2][2] = QUEEN;
		Board[4][3] = QUEEN;

		System.out.println(Check(2, 2));
	}
}

/*
 * public static void place(int x, int y) { if (Board[x][y] == EMPTY) {
 * Board[x][y] = 1; for (int i = 0; i < n; i++) { int xDiff = i - x ; if
 * (Board[i][y] != QUEEN) Board[i][y] = BLOCKED; if (y + xDiff < n && Board[i][y
 * + xDiff] != QUEEN) Board[i][y + xDiff] = BLOCKED; } int otherCount = y; for
 * (int i = x; i > 0; i--) { int xDiff = x - i; if (y + xDiff < n) { if
 * (Board[i][y + xDiff] != QUEEN) Board[i][y + xDiff] = BLOCKED; } if (y - xDiff
 * >= 0) { if (Board[i][y - xDiff] != QUEEN) Board[i][y - xDiff] = BLOCKED; } }
 * for (int i = 0; i < n; i++) { if (Board[x][i] != QUEEN) Board[x][i] =
 * BLOCKED; }
 * 
 * } if (x + 1 < n) place(x + 1, y); if (y + 1 < n) place(x, y + 1); }
 */